package com.oritsh.hl7;

import ca.uhn.hl7v2.DefaultHapiContext;
import ca.uhn.hl7v2.HL7Exception;
import ca.uhn.hl7v2.HapiContext;
import ca.uhn.hl7v2.app.Connection;

/**
 * Created with IntelliJ IDEA.
 * User: zarra
 * Date: 14-3-15
 * Time: 上午11:13
 * Copyright Shanghai Orient Rain Information Technology Co.,Ltd.
 */
public class ClientFactory {
    private String hostname;
    private int port;
    private boolean tls;

    private HapiContext context = new DefaultHapiContext();

    public String getHostname() {
        return hostname;
    }

    public void setHostname(String hostname) {
        this.hostname = hostname;
    }

    public int getPort() {
        return port;
    }

    public void setPort(int port) {
        this.port = port;
    }

    public boolean isTls() {
        return tls;
    }

    public void setTls(boolean tls) {
        this.tls = tls;
    }

    public HapiContext getContext() {
        return context;
    }

    public void setContext(HapiContext context) {
        this.context = context;
    }

    public Client createClient() throws HL7Exception {
        HapiContext context = new DefaultHapiContext();
        Connection connection = context.newClient(hostname, port, tls);
        return new Client(connection);
    }
}
